// pages/myself/points/points.js
const { imageUrl } = require("../../../utils/http/http").dev
const { getGoods,getUserInfo,buyGood } = require("../../../utils/http/api")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shopImg: imageUrl + "/商城.png",
    show: false,
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
    shopList: [{
      img: imageUrl + "/good-3.png",
      title: "小米充电宝",
      content: "16000积分",
      sales: '666',
      remain: '100'
    }, {
      img: imageUrl + "/good-5.png",
      title: "安恒信息手提帆布包",
      content: "8500积分",
      sales: '666',
      remain: '100'
    }, {
      img: imageUrl + "/good-2.png",
      title: "《数据安全与隐私计算》",
      content: "12000积分",
      sales: '666',
      remain: '100'
    }, {
      img: imageUrl + "/good-1.png",
      title: "赛事安保吉祥物“安恒小龙人...",
      content: "7500积分",
      sales: '666',
      remain: '100'
    }, {
      img: imageUrl + "/good-4.png",
      title: "绿色环保活动大会定制背包",
      content: "18000积分",
      sales: '666',
      remain: '100'
    }, {
      img: imageUrl + "/good-6.png",
      title: "“安恒信息 安全亚运”纪念徽章",
      content: "9500积分",
      sales: '666',
      remain: '100'
    }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getUserInfo()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  getUserInfo(){
    getUserInfo(3).then(res => {
      console.log("point",res)
      this.setData({
        point:res.data.points
      })
    })
  },
  //兑换记录
  toChange(){
    wx.navigateTo({  
      url: '/pages/myself/points/pointsChange/pointsChange'  
    });  
  },

  //积分规则
  showPopup() {
    var _this = this
    _this.setData({ show: true });
  },

  onClose() {
    var _this = this
    _this.setData({ show: false });
  },
  
  

  //兑换
  toRedeem(){
    wx.showModal({
      title: '提示',
      content: '是否兑换商品',
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定')
          wx.showToast({
            title: '积分不足哦~',
            icon: 'error'
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
    注意
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})